<!--
  - ProcessCreateAccount.php
  - v0.01
  - 2/1/2011
  -
  -	This source code calls the InsertNewUser() function which determines if
  - the parameters are inserted to the database correctly. This redirects to a
  - success page if the insertion is successful, else, it will be redirected
  - to an error flagged page.
  -->
<?php 
	require 'libraries/LoginLib.php';
	require 'libraries/UserLibrary.php';
	session_start();
	isSessionSet("administrator", NULL, "AdministratorHomepage.php");
	
	$username =  $_POST['username'];
	$password = $_POST['password1'];
	$userType = $_POST['usertype'];
	$name =  $_POST['name'];
	$title =  $_POST['title'];
	$position =  $_POST['position'];
	
	/*Insert the new account into the database.*/
	$login = InsertNewUser($username, $password, $userType, $name, $title,
			$position, "casl", "localhost", "createaccount", "createaccount");
	
	/*Check if the insertion is successful.*/
	if($login == TRUE){
		header("Location: Logout.php");
	}else{
		header("Location: CreateAccount.php?error=true");
	}
?>